<template>
	<view class="waterfall-item" @tap="onTap">
		<image :src="params.nft.img" mode="widthFix" @load="emitHeight" @error="emitHeight"></image>
		<view class="content">
			<u-text
				:text="params.nft.name"
				size="28rpx"
				color="#000000"
			></u-text>
			<view class="seller-price" v-if="params.minMoney != params.maxMoney">
				<view class="text-1">
					<u-text
						:text="params.minMoney"
						color="#356CE7"
						bold
						size="34rpx"
						prefixIcon="rmb"
						block
						iconStyle="font-size: 26rpx; color: #356CE7; font-weight: bold;top: 10rpx;"
					></u-text>
				</view>
				<view class="seller-price-bl">~</view>
				<view class="text-1">
					<u-text
						:text="params.maxMoney"
						:lines="1"
						color="#356CE7"
						bold
						size="34rpx"
						prefixIcon="rmb"
						block
						iconStyle="font-size: 26rpx; color: #356CE7; font-weight: bold;top: 10rpx;"
					></u-text>
				</view>
			</view>
			<view class="seller-price" v-else>
				<u-text
					:text="params.maxMoney"
					color="#356CE7"
					bold
					size="34rpx"
					prefixIcon="rmb"
					block
					iconStyle="font-size: 26rpx; color: #356CE7; font-weight: bold;top: 10rpx;"
				></u-text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"helang-waterfall",
		props:{
			params:{
				type: Object,
				default(){
					return {}
				}
			},
			tag:{
				type:String | Number,
				default:''
			},
			index:{
				type:Number,
				default:-1
			}
		},
		data() {
			return {

			};
		},
		methods:{
			// 发出组件高度信息，在此处可以区分正确和错误的加载，给予错误的提示图片
			emitHeight(e){
				const query = uni.createSelectorQuery().in(this);
				query.select('.waterfall-item').boundingClientRect(data => {
					let height = Math.floor(data.height);
					this.$emit("height",height,this.$props.tag);
				}).exec();
			},
			onTap(){
				this.$emit("click",this.$props.index,this.$props.tag);
			}
		}
	}
</script>

<style lang="scss" scoped>
.waterfall-item{
	background-color: #ffffff;
	border-radius: 14rpx;
	margin-bottom: 20rpx;
	overflow: hidden;
	image{
		display: block;
		width: 100%;
		// 默认设置一个图片的大约值
		height: 350rpx;
	}
	.content{
		padding: 20rpx 14rpx 26rpx 14rpx;
		.seller-price {
			display: flex;
			align-items: center;
			margin-top: 12rpx;
			.seller-price-bl {
				margin: 0 7rpx;
				font-size: 26rpx;
				font-family: PingFangSC-Semibold, PingFang SC;
				font-weight: 600;
				color: #356CE7;
			}
		}
	}
}
</style>
